namespace SharpTalk.Core.Base
{
    using Interfaces;
    using Enums;
    using EventArgs;
    using Diagnostic;
    using System.Diagnostics;
    using System.Reflection;

    public abstract class MessageHandlerBase : Traceable, IMessageHandler
    {
        /// <summary>
        /// Initialiazes a new instance
        /// </summary>
        /// <param name="traceProvider"></param>
        protected MessageHandlerBase(ITraceProvider traceProvider)
        {
            TraceProvider = traceProvider;
        }

        /// <summary>
        /// Determines if a message handler can handle type of message.
        /// </summary>
        /// <param name="messageType">A MessageTypeEnum value</param>
        /// <returns>True if the handler can handle it otherwise false</returns>
        public virtual bool CanHandle(MessageTypeEnum messageType) 
        { 
            if (ShouldTrace(TraceEventType.Verbose)) TraceMethodCall(MethodBase.GetCurrentMethod()); 
            return false; 
        }
        /// <summary>
        /// Handles the message
        /// </summary>
        /// <param name="message"></param>
        public abstract void HandleMessage(object message, MessageHandleEventArgs e);
    }
    
}